<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 2 | Dashboard</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">


    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" th:href="@{/bower_components/bootstrap/dist/css/bootstrap.min.css}" type="text/css">

    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/bower_components/font-awesome/css/font-awesome.min.css}" type="text/css">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/bower_components/Ionicons/css/ionicons.min.css}" type="text/css">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/dist/css/AdminLTE.min.css}" type="text/css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/dist/css/skins/_all-skins.min.css}" type="text/css">
    <!-- Morris chart -->
    <link rel="stylesheet" th:href="@{/bower_components/morris.js/morris.css}" type="text/css">
    <!-- jvectormap -->
    <link rel="stylesheet" th:href="@{/bower_components/jvectormap/jquery-jvectormap.css}" type="text/css">
    <!-- Date Picker -->
    <link rel="stylesheet" th:href="@{/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css}"
          type="text/css">
    <!-- Daterange picker -->
    <link rel="stylesheet" th:href="@{/bower_components/bootstrap-daterangepicker/daterangepicker.css}" type="text/css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" th:href="@{/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css}" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">

    <link rel="stylesheet" th:href="@{/css/mycss.css}" type="text/css">




</head>
<body class="hold-transition skin-blue sidebar-mini fixed">
<div class="wrapper">
    <header class="main-header">
        <div th:include="common/head :: head"></div>
    </header>
    <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar">

            <div th:include="common/left :: left"></div>
        </section>
        <!-- /.sidebar -->
    </aside>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">

        <h2 class="profile-username text-center" href="/aaa">上传课程介绍</h2>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- /.col -->
                <div class="col-md-12">
                    <div class="nav-tabs-custom">
                        <div class="tab-content">
                            <form class="form-horizontal" action="/savecoursedescribe" method="post" id="myform" enctype="multipart/form-data">
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-2 control-label">课程名称</label>

                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="inputNam" placeholder="请输入课程名称"
                                               name="coursename" th:value="${coursename}">
                                        <span></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputName1" class="col-sm-2 control-label">课程首图</label>

                                    <div class="col-sm-10">
                                        <input type="file" class="form-control" id="inputName1"
                                                name="img" th:id="file" th:onchange="checkimgaaa()">
                                        <span></span>
                                        <img class=" img-lg  ying" th:src="${imgpath}" alt="User profile picture" th:id="img" >

                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputName" class="col-sm-2 control-label">价格</label>

                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="inputName"
                                               placeholder="请输入价格，免费输入0元" name="price" th:value="${#numbers.formatDecimal(price,0,2)}">
                                        <span></span>
                                    </div>
                                </div>


                                <div class="form-group">
                                    <label for="inputExperience" class="col-sm-2 control-label">课程描述</label>

                                    <div class="col-sm-10">
                                        <textarea class="form-control" id="inputExperience" placeholder="请输入课程描述。。。"
                                                  name="simpledescribe" th:text="${simpledescribe}"></textarea>
                                        <span></span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">类别</label>
                                    <div class="col-sm-10">
                                        <select name="categoryid" th:id="categoryid">
                                            <option th:each="u:${categorys}"
                                                    th:value="${u.categoryid}"
                                                    th:text="${u.categoryname}"
                                            >
                                            </option>
                                        </select>
                                        <input th:type="text" th:value="${categoryname}" class="ying " readonly id="categoryname">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">难度</label>
                                    <div class="col-sm-10">
                                        <select name="differentid" th:id="differentid">
                                            <option th:each="c:${courseDifferents}"
                                                    th:value="${c.differentid}"
                                                    th:text="${c.differentname}"
                                                    >
                                            </option>
                                        </select>
                                        <input th:type="text" th:value="${differentname}" class="ying" readonly id="differentidname">
                                    </div>
                                </div>


                                <div class="form-group" style="text-align: center">
                                    <div class="col-sm-offset-2 col-sm-12">
                                        <button type="submit" class="btn btn-primary " th:id="mysave" onclick="save()">提交保存</button>
                                        <a th:href="addchapter" th:id="xiayibu" class="ying"><button type="button" class="btn btn-primary " th:id="mysave">下一步</button></a>
                                    </div>
                                </div>
                            </form>
                            <!-- /.tab-pane -->
                        </div>
                        <!-- /.tab-content -->
                    </div>
                    <!-- /.nav-tabs-custom -->
                </div>
                <!-- /.col -->
            </div>
            <!-- /.row -->
        </section>
        <!-- /.content -->


    </div>
    <!-- /.content-wrapper -->
    <footer class="main-footer">
        <div th:include="common/footer :: footer"></div>
    </footer>
    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script th:src="@{/bower_components/jquery/dist/jquery.min.js}" type="text/javascript"></script>
<!-- jQuery UI 1.11.4 -->
<script th:src="@{/bower_components/jquery-ui/jquery-ui.min.js}" type="text/javascript"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.7 -->
<script th:src="@{/bower_components/bootstrap/dist/js/bootstrap.min.js}" type="text/javascript"></script>
<!-- Morris.js charts -->
<script th:src="@{/bower_components/raphael/raphael.min.js}" type="text/javascript"></script>
<script th:src="@{/bower_components/morris.js/morris.min.js}" type="text/javascript"></script>
<!-- Sparkline -->
<script th:src="@{/bower_components/jquery-sparkline/dist/jquery.sparkline.min.js}" type="text/javascript"></script>
<!-- jvectormap -->
<script th:src="@{/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js}" type="text/javascript"></script>
<script th:src="@{/plugins/jvectormap/jquery-jvectormap-world-mill-en.js}" type="text/javascript"></script>
<!-- jQuery Knob Chart -->
<script th:src="@{/bower_components/jquery-knob/dist/jquery.knob.min.js}" type="text/javascript"></script>
<!-- daterangepicker -->
<script th:src="@{/bower_components/moment/min/moment.min.js}" type="text/javascript"></script>
<script th:src="@{/bower_components/bootstrap-daterangepicker/daterangepicker.js}" type="text/javascript"></script>
<!-- datepicker -->
<script th:src="@{/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js}"
        type="text/javascript"></script>
<!-- Bootstrap WYSIHTML5 -->
<script th:src="@{/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js}" type="text/javascript"></script>
<!-- Slimscroll -->
<script th:src="@{/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}" type="text/javascript"></script>
<!-- FastClick -->
<script th:src="@{/bower_components/fastclick/lib/fastclick.js}" type="text/javascript"></script>
<!-- AdminLTE App -->
<script th:src="@{/dist/js/adminlte.min.js}" type="text/javascript"></script>
<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
<script th:src="@{/dist/js/pages/dashboard.js}" type="text/javascript"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/dist/js/demo.js}" type="text/javascript"></script>


<script type="text/javascript">
    $(function () {
        $('.sidebar-menu li:not(.treeview) > a').on('click', function () {
            console.log(this.href);
            var $parent = $(this).parent().addClass('active');
            $parent.siblings('.treeview.active').find('> a').trigger('click');
            $parent.siblings().removeClass('active').find('li').removeClass('active');
        });
        $('.sidebar-menu a').each(function () {
            if (this.href === window.location.href) {
                $(this).parent().addClass('active')
                    .closest('.treeview-menu').addClass('.menu-open')
                    .closest('.treeview').addClass('active');
            }
        });


    });

</script>
<script type="text/javascript">

    //对上传的图片文件类型进行限制
    function checkimgaaa() {
        var aa = document.getElementById("file").value.toLowerCase().split(".");
        /*以.分割文件字符串*/

        if (aa[aa.length - 1] == 'jpg' || aa[aa.length - 1] == 'png') {

        } else {
            document.getElementById("file").value = '';
            alert("格式不对,只能上传.jpg和.png类型的图片");
        }
    }

    $("[name=coursename]").blur(function () {
        if ($("[name=coursename]").val() != "") {
            $("[name=coursename]").next().text("");
        } else {
            $("[name=coursename]").next().text("不能为空").css("color", "red");
        }
    });
    $("[name=img]").blur(function () {
        if ($("[name=img]").val() != "") {
            $("[name=img]").next().text("");

        } else {
            $("[name=img]").next().text("不能为空").css("color", "red");
        }
    });
    $("[name=price]").blur(function () {
        if ($("[name=price]").val() != "") {
            $("[name=price]").next().text("");

            var price=$("[name=price]").val();
            var patrn = /^[0-9]*$/;
            if (!patrn.test(price)) {
                document.getElementById("inputName").value = '';

                $("[name=price]").next().text("只能输入数字").css("color", "red");
            }



        } else {
            $("[name=price]").next().text("不能为空").css("color", "red");
        }
    });
    $("[name=simpledescribe]").blur(function () {
        if ($("[name=simpledescribe]").val() != "") {
            $("[name=simpledescribe]").next().text("");

        } else {
            $("[name=simpledescribe]").next().text("不能为空").css("color", "red");
        }
    });




    /*保存操作*/
    function save() {
        var a = $("[name=coursename]").val();
        var ee = $("[name=img]").val();
        var f = $("[name=price]").val();
        var i = $("[name=simpledescribe]").val();


        if (a == "" || ee == "" || f == "" || i == "") {
            $("#myform").bind("submit", (function (e) {
                e.preventDefault();
            }));
            confirm("输入的信息有误，请重新检查");
        } else {
            $("#myform").unbind("submit");
            confirm("确认保存？");
        }
    }
</script>















<!--下个页面独有的js-->
<script type="text/javascript">

    var i=[[${i}]];
    if(i==1){
        var file=document.getElementById("file");
        file.style.display = "none";
        var img=document.getElementById("img");
        img.style.display = "block";
        var categoryid=document.getElementById("categoryid");
        categoryid.style.display = "none";
        var differentid=document.getElementById("differentid");
        differentid.style.display = "none";
        var categoryname=document.getElementById("categoryname");
        categoryname.style.display = "block";
        var differentidname=document.getElementById("differentidname");
        differentidname.style.display = "block";
        var mysave=document.getElementById("mysave");
        mysave.style.display = "none";
        var xiayibu=document.getElementById("xiayibu");
        xiayibu.style.display = "block";
        alert("上传成功！");
    }else {
        alert("保存失败！")
    }



</script>
</body>
</html>
